package kr.kosta.servlet;

import java.io.UnsupportedEncodingException;

import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class HelloServlet extends HttpServlet {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	public void doGet(HttpServletRequest req, HttpServletResponse resp) throws UnsupportedEncodingException
	{
		System.out.println("Hello Servlet. GET");
		
//		req.setCharacterEncoding("UTF-8");//전체에 UTF-8로 적용
		String name = req.getParameter("name");
		String encodedName = new String(name.getBytes("ISO8859-1"), "UTF-8");//개별 UTF-8로 적용 : servlet 자체가 ISO8859-1이 기본이기 때문에 ...
		System.out.println("Welcome " + name + "님 환영합니다.");
		
	}
	
	public void doPost(HttpServletRequest req, HttpServletResponse resp) throws UnsupportedEncodingException
	{
		System.out.println("Hello Servlet. POST");

//		req.setCharacterEncoding("UTF-8");//전체에 UTF-8로 적용
		String name = req.getParameter("name");
		String encodedName = new String(name.getBytes("ISO8859-1"), "UTF-8");//개별 UTF-8로 적용 : servlet 자체가 ISO8859-1이 기본이기 때문에 ...
		System.out.println("Welcome " + name + "님 환영합니다.");
	}
}
